package cn.learn.server;

import cn.learn.server.persistence.FileTxnSnapLog;

import java.util.concurrent.atomic.AtomicInteger;

public class ZKDatabase {
    protected DataTree dataTree;
    private volatile boolean initialized = false;
    protected FileTxnSnapLog snapLog;

    private AtomicInteger txnCount = new AtomicInteger(0);

    public ZKDatabase() {
        dataTree = createDataTree();
    }

    public DataTree createDataTree() {
        return new DataTree();
    }

    public boolean isInitialized() {
        return initialized;
    }

    public long loadDataBase() {
        initialized = true;
        return 1L;
    }

    public DataNode getNode(String path) {
        return dataTree.getNode(path);
    }

    public boolean append(Request si) {
//        if (this.snapLog.append(si)) {
//            txnCount.incrementAndGet();
//            return true;
//        }
//        return false;
        return true;
    }

    public DataTree getDataTree() {
        return this.dataTree;
    }
}
